<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<ul class="breadcrumb">
			<li>
				<i class="icon-home home-icon"></i>
				<a href="#">系统首页</a>
			</li>
			<li class="active">
				报表管理
			</li>
            <li class="active">
				测量统计
			</li>
		</ul><!-- .breadcrumb -->
	</div>
	<div class="page-content">
    	<div class="row">
    	    <div class="page-header">
    			<h1>测量统计</h1>
    		</div>
    		<div class=" col-md-12 col-sm-12 col-xs-12 form">
                <div class="row">
                <form action="<?php echo base_url().'admin/count/query_order_count'?>" method="get">
                    <div class="col-xs-6">
                    	<label>选择周期：</label>
                        <input type="text"  name="date1" id="date1" value="<?php if (isset($date1))echo $date1;?>" style="display: inline-block;width:25%;" />
                        <label style="display: inline-block;">———</label>
                        <input id="date2" name="date2" style="display: inline-block;width:25%;" value="<?php if (isset($date2))echo $date2;?>" type="text" class="form-control">
                        <button class="btn btn-sm btn-info" type="submit"><i class="icon-search"></i>统计</button>
                    
                        <?php if (isset($result)&&count($result)>0){?>
                            <a class="btn btn-sm btn-warning" href="<?php echo base_url().'admin/count/order_excel';?>"><i class="icon-download"></i>导出</a>
                        <?php }else {?>
                            <a class="btn btn-sm btn-warning" href="#" onclick="show_content()"><i class="icon-download"></i>导出</a>
                        <?php }?>
                    
                    </div>
                    <div class="col-xs-3"><?php if (isset($message)){echo "<font color=red>$message</font>"; }?></div>
                </form>
                </div>
            </div>
            
            <br><br>
            
            <div class="col-sm-6" >
			     <div class="widget-box">
    			     <div class="widget-body">
    			         <div class="widget-header widget-header-flat widget-header-small">
        					<h5>
        						<i class="icon-signal"></i>
        						每日新增订单统计
        					</h5>
    					</div>
    					<div id="main_info_1" ></div>
    				</div>
			     </div>
		    </div>
		    <div class="col-sm-6" >
			     <div class="widget-box">
    			     <div class="widget-body">
    			         <div class="widget-header widget-header-flat widget-header-small">
        					<h5>
        						<i class="icon-signal"></i>
        						订单状态分布
        					</h5>
    					</div>
    					<div id="main_info_2" ></div>
    				</div>
			     </div>
		    </div>
		    <div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
					<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th class="center">
									<label>
										<input type="checkbox" class="ace" />
										<span class="lbl"></span>
									</label>
								</th>
								<th>订单编号</th>
								<th>下单用户</th>
                                <th>手机号码</th>
                                <th>设备大类</th>
                                <th>设备规格</th>
                                <th>订单状态</th>
                                <th>支付方式</th>
                                <th>支付状态</th>
                                <th>订单总额</th>
                                <th>订单类型</th>
                                <th>联系人姓名</th>
                                <th>联系人电话</th>
                                <th>下单时间</th>
							</tr>
						</thead> 
						<tbody>
						<?php if (isset($result)&&count($result)>0){
						foreach ($result as $app){?>
						    <tr>
								<td class="center">
                                	<p>
									<label>
										<input type="checkbox" class="ace" name="num[]" value=""/>
										<span class="lbl"></span>
									</label>
                                    </p>
								</td>
								<td><p><?php echo $app->order_no;?></p></td>
                                <td><p><?php echo $app->user_name;?></p></td>
                                <td><p><?php echo $app->user_phone;?></p></td>
                                <td><p><?php echo $app->category_name;?></p></td>
                                <td><p><?php echo $app->type_name;?></p></td>
                                <td><p><?php 
                                	if($app->status == 0){
                                		echo "未完成";
                                	}elseif($app->status == 1){
                                		echo "抢单中";
                                	}elseif($app->status == 2){
                                		echo "等待客户确认";
                                	}elseif($app->status == 3){
                                		echo "确认使用";
                                	}elseif($app->status == 4){
                                		echo "致电客户";
                                	}elseif($app->status == 5){
                                		echo "确认开始";
                                	}elseif($app->status == 6){
                                		echo "确认结束";
                                	}elseif($app->status == 7){
                                		echo "订单取消";
                                	}elseif($app->status == 8){
                                		echo "投诉中";
                                	}
                                	?></p></td>
                                <td><p><?php echo $app->payment;?></p></td>
                                <td><p><?php 
                                	if($app->payment_status == 0){
                                		echo "未支付";
                                	}elseif($app->payment_status == 1){
                                		echo "已支付";
                                	}
                                	?></p></td>
                            	<td><p><?php echo $app->order_price.'+'.$app->order_tip;?></p></td>
                            	<td><p><?php 
                                	if($app->order_type == 1){
                                		echo "即时";
                                	}elseif($app->order_type == 2){
                                		echo "预约";
                                	}
                                	?></p></td>
                            	<td><p><?php echo $app->contact_name;?></p></td>
                            	<td><p><?php echo $app->contact_phone;?></p></td>
                                <td><p><?php echo $app->create_time;?></p></td>
    						</tr>
						<?php }
						}else{?>
						<tr>
                        	<td colspan="14">无数据</td>
                        </tr>
                            <?php }?>
						</tbody>
						</table>
                 </div><!-- /.table-responsive -->
			</div>
			<div class="col-sm-12">
            	<div class="modal-footer no-margin-top">
                	<div class="pull-left record">
						共<?php if (isset($count))echo $count;else echo 0;?>条记录
                    </div>
            		<?php if (isset($page))echo $page;?>
            	</div>
            </div>
            </div><!-- /.row -->
		</div><!-- /.page-content -->
	</div><!-- /.main-content -->
	<script type="text/javascript">
	var main_info_1 = document.getElementById('main_info_1');
	var main_info_2 = document.getElementById('main_info_2');
	
	//用于使chart自适应高度和宽度,通过窗体高宽计算容器高宽
	var resizeWorldMapContainer = function () {
		ht=window.innerHeight-140;
	    main_info_1.style.height = ht/2 +'px';
		main_info_2.style.height = ht/2 +'px';
		
	};
	//设置容器高宽
	resizeWorldMapContainer();
	$(function(){
		loadData1();
		loadData2();
	}); 
	var myChart_1 = echarts.init(document.getElementById('main_info_1'));
	function loadData1(){
		
		option1 = {
			    tooltip : {
			        trigger: 'axis',
			        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
			            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
			        }
			    },
			    legend: {
			        data:['订单数量']
			    },
			    grid: {
			    	x: '25px',
			        y: '30px',
			        x2: '25px',
			    },
			    xAxis : [
			        {
			            type : 'category',
			            axisLabel: {  
				            interval:0,  
				            rotate:40  
				         }  ,
			            data : [<?php if (isset($date)&&count($date)>0){foreach ($date as $val){echo "'".$val."',";}}?>]
			        },
			        
			    ],
			    yAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'数量',
			            type:'bar',
			            data:[<?php if (isset($order)&&count($order)>0){foreach ($order as $val){echo $val.",";}}?>]
			        },
			    ]
			};
			myChart_1.setOption(option1);
	}
	var myChart_2 = echarts.init(document.getElementById('main_info_2'));
	function loadData2(){
		
		myChart_2.setOption({
    		tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                x: 'left',
                data: ['未完成','抢单中','等待客户确认','确认使用','致电客户','确认开始','确认结束','订单取消','投诉中']
            },
            toolbox: {
                show : true,
                feature : {
                    mark : {show: true},
                    dataView : {show: true, readOnly: false},
                    magicType : {
                        show: true, 
                        type: ['pie', 'funnel'],
                        option: {
                            funnel: {
                                x: '25%',
                                width: '50%',
                                funnelAlign: 'left',
                                max: 1548
                            }
                        }
                    },
                    restore : {show: true},
                    saveAsImage : {show: true}
                }
            },
            calculable : true,
            series : [
                {
                    name:'用户数量',
                    type:'pie',
                    radius : '55%',
                    center: ['50%', '60%'],
                    data:[
							{value:<?php if (isset($count0))echo $count0;else echo 0;?>, name:'未完成'},
                            {value:<?php if (isset($count1))echo $count1;else echo 0;?>, name:'抢单中'},
                            {value:<?php if (isset($count2))echo $count2;else echo 0;?>, name:'等待客户确认'},
                            {value:<?php if (isset($count3))echo $count3;else echo 0;?>, name:'确认使用'},
                            {value:<?php if (isset($count4))echo $count4;else echo 0;?>, name:'致电客户'},
                            {value:<?php if (isset($count5))echo $count5;else echo 0;?>, name:'确认开始'},
                            {value:<?php if (isset($count6))echo $count6;else echo 0;?>, name:'确认结束'},
                            {value:<?php if (isset($count7))echo $count7;else echo 0;?>, name:'订单取消'},
                            {value:<?php if (isset($count8))echo $count8;else echo 0;?>, name:'投诉中'},
                          ]
                }
            ]
    	});
	}
	window.onresize = function () {
	    //重置容器高宽
	    resizeWorldMapContainer();
	    myChart_1.resize();
		myChart_2.resize();
		
	}; 
	$(function () {
        $('#date1').datetimepicker({
            format: 'yyyy-mm-dd', 'autoclose': true, minView: 2,language: 'zh-CN'
        });
        $('#date2').datetimepicker({
            format: 'yyyy-mm-dd', 'autoclose': true, minView: 2,language: 'zh-CN'
        });
    });
    function show_content(){
        alert("暂无数据！");
    }
	</script>